package git.soulbgm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import git.soulbgm.cache.annotation.Group;
import git.soulbgm.cache.enumeration.TimeLevel;
import git.soulbgm.mapper.PacketReceiveSequenceMapper;
import git.soulbgm.pojo.PacketReceiveSequence;
import git.soulbgm.service.PacketReceiveSequenceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

import static git.soulbgm.common.Constants.*;

/**
 * 分组接收序列服务实现
 *
 * @author SoulBGM
 * @date 2024-09-23
 */
@Service
public class PacketReceiveSequenceServiceImpl extends ServiceImpl<PacketReceiveSequenceMapper, PacketReceiveSequence> implements PacketReceiveSequenceService {

    @Transactional(rollbackFor = Exception.class)
    @Group(groupName = GN_RECEIVE_DATA,
            groupBy = {"sourceCode", "dataType"}, aggregation = {"COUNT(packetId)", "SUM(dataSegmentLength)"},
            timeLevel = TimeLevel.MINUTE, dateField = "packetDate")
    @Override
    public boolean saveBatch(Collection<PacketReceiveSequence> entityList) {
        return super.saveBatch(entityList);
    }
}
